import { defineStore } from "pinia";

export const useUserStore = defineStore("userStore", {
  state: () => {
    return {
      userList: [
        {
          id: "9aa0",
          name: "张三",
          age: "14",
          phone: "13112341234",
          email: "414@qq.com",
          education: "本科",
          graduationschool: "渡一大学",
          profession: "前端开发",
          profile: "我不会下班～",
        },
        {
          id: "90f4",
          name: "121",
          age: "1",
          phone: "1",
          email: "1",
          education: "本科",
          graduationschool: "1",
          profession: "1",
          profile: "1",
        },
        {
          id: "f9c6",
          name: "李四",
          age: "19",
          phone: "13112341234",
          email: "123@qq.om",
          education: "本科",
          graduationschool: "四川大学",
          profession: "教师",
          profile: "Hello～",
        },
        {
          id: "f39f",
          name: "王五",
          age: "37",
          phone: "18200126922",
          email: "解放路12号",
          education: "硕士",
          graduationschool: "清华大学",
          profession: "HR",
          profile: "Helloooooo～",
        },
        {
          id: "21a5",
          name: "老刘",
          age: "40",
          phone: "13112341234",
          email: "131@qq.com",
          education: "本科",
          graduationschool: "北京大学",
          profession: "会计",
          profile: "钱快来，钱快来，钱从四面八方来！",
        },
        {
          id: "c470",
          name: "小陈",
          age: "23",
          phone: "17934237456",
          email: "345@qq.com",
          education: "本科",
          graduationschool: "渡一大学",
          profession: "前端",
          profile: "帮我看看这句代码对不对～",
        },
      ],
    };
  },
  getters: {
    getUserList: (state) => state.userList,
  },
  actions: {
    getUserById(id) {
      return this.userList.find((item) => item.id === id);
    },
  },
});
